// https://umijs.org/config/
import { defineConfig } from 'umi';
import defaultSettings from './defaultSettings';
// import proxy from './proxy';
// Do this as the first thing so that any code reading it knows the right env.
const { cdnUrl } = require("./ossUrl");
const { REACT_APP_ENV } = process.env;
export default defineConfig({
  hash: true,
  antd: {},
  dva: {
    hmr: true,
  },
  locale: {
    // default zh-CN
    default: 'zh-CN',
    // default true, when it is true, will use `navigator.language` overwrite default
    antd: true,
    baseNavigator: true,
  },
  dynamicImport: {
    loading: '@/components/PageLoading/index',
  },
  targets: {
    ie: 11,
  },
  // umi routes: https://umijs.org/docs/routing
  routes: [
    {
      path: '/user',
      component: '../layouts/UserLayout',
      routes: [
        {
          name: 'login',
          path: '/user/login',
          component: './user/login',
        },
      ],
    },

    {
      path: '/add',
      component: './CourseInfo/AddRecords'
    },
    {
      path: '/',
      component: '../layouts/SecurityLayout',
      routes: [
        {
          path: '/',
          component: '../layouts/BasicLayout',
          routes: [
            {
              path: '/',
              redirect: '/course/list',
            },
            {
              path: '/game-list',
              component: './CourseInfo/Game',
            },
            {
              path: '/class-list',
              component: './Class/List',
            },
            {
              path: '/tag-list',
              component: './Tag/List',
              routes: [
                {
                  name: 'tag-list',
                  path: '/Tag/List',
                  component: './Tag/List',
                  hideInMenu: true
                },
              ],
            },
            {
              path: '/send-list',
              component: './Send/List',
              routes: [
                {
                  name: 'send-list',
                  path: '/Send/List',
                  component: './Send/List',
                  hideInMenu: true
                },
              ],
            },
            {
              path: '/paper-list',
              component: './Paper/List',
              routes: [
                {
                  name: 'paper-list',
                  path: '/Paper/List',
                  component: './Paper/List',
                  hideInMenu: true
                },
              ],
            },
            {
              path: '/activity',
              name: 'activity',
              icon: 'crown',
              authority: ['admin'],
              routes: [
                {
                  path: '/activity/activity-data',
                  name: 'activity-data',
                  icon: 'smile',
                  component: './Activity/ActivityData',
                  authority: ['admin'],

                },
                {
                  path: '/activity/activity-class-data',
                  name: 'activity-class-data',
                  icon: 'smile',
                  component: './Activity/ActivityClassData',
                  authority: ['admin'],
                  hideChildrenInMenu: true,
                  hideInMenu: true

                },
              ],

            },
            {
              path: '/quiz',
              name: 'quiz',
              icon: 'crown',
              authority: ['admin'],
              routes: [
                {
                  path: '/quiz/quiz-data',
                  name: 'quiz-data',
                  icon: 'smile',
                  component: './Quiz/QuizData',
                  authority: ['admin'],

                },
                {
                  path: '/quiz/quiz-data-detail',
                  name: 'quiz-data-detail',
                  icon: 'smile',
                  component: './Quiz/QuizDetail',
                  authority: ['admin'],
                  hideChildrenInMenu: true,
                  hideInMenu: true

                },
                {
                  path: '/quiz/task-search',
                  name: 'task-search',
                  icon: 'smile',
                  component: './Task/search.tsx',
                  authority: ['admin'],

                },
                {
                  path: '/quiz/task-detail',
                  name: 'task-detail',
                  icon: 'smile',
                  component: './Task/index.tsx',
                  authority: ['admin'],
                  hideChildrenInMenu: true,
                  hideInMenu: true

                }
              ],
            },

            {
              path: '/game',
              name: 'game',
              icon: 'crown',
              authority: ['admin'],
              routes: [
                {
                  path: '/game/game-data',
                  name: 'game-data',
                  icon: 'smile',
                  component: './Game/GameData',
                  authority: ['admin'],

                },
                {
                  path: '/game/game-data-detail',
                  name: 'game-data-detail',
                  icon: 'smile',
                  component: './Game/GameDetailData',
                  authority: ['admin'],
                  hideChildrenInMenu: true,
                  hideInMenu: true

                },
                {
                  path: '/game/game-list',
                  name: 'game-list',
                  icon: 'smile',
                  component: './Game/GameList',
                  authority: ['admin'],
                  hideChildrenInMenu: true,
                  hideInMenu: true

                },
              ],
            },
            {
              path: '/export',
              name: 'export',
              icon: 'crown',
              authority: ['admin'],
              routes: [
                {
                  path: '/export/step-export',
                  name: 'step-export',
                  icon: 'smile',
                  component: './DataExport/StepLearn',
                  authority: ['admin'],

                },

              ],
            },
            {
              path: '/learn',
              name: 'learn',
              icon: 'crown',
              authority: ['admin'],
              routes: [
                {
                  path: '/learn/learn-search',
                  name: 'learn-search',
                  icon: 'smile',
                  component: './Learn',
                  authority: ['admin'],
                },
                {
                  path: '/learn/learn-detail',
                  name: 'learn-detail',
                  icon: 'smile',
                  component: './Learn/Detail',
                  authority: ['admin'],
                  hideChildrenInMenu: true,
                  hideInMenu: true
                },
                {
                  path: '/learn/learn-step',
                  name: 'learn-step',
                  icon: 'smile',
                  component: './Learn/Steps',
                  authority: ['admin'],
                  hideChildrenInMenu: true,
                  hideInMenu: true
                },
              ],
            },
            {
              path: '/course',
              name: 'course',
              icon: 'crown',
              routes: [
                {
                  path: '/course/list',
                  name: 'course-list',
                  icon: 'smile',
                  component: './OwnCourse/index',
                },
                {
                  path: '/course/info',
                  icon: 'smile',
                  component: './CourseInfo/index',
                },
                {
                  path: '/course/userGame/chess',
                  // name: 'course-detail',
                  hideInMenu: true,
                  icon: 'smile',
                  component: './UserGame/index',
                },
                {
                  path: '/course/chess',
                  // name: 'course-detail',
                  hideInMenu: true,
                  icon: 'smile',
                  component: './ViewChess/index',
                },
                {
                  path: '/course/black',
                  // name: 'course-detail',
                  hideInMenu: true,
                  icon: 'smile',
                  component: './blackView/index',
                },
                {
                  path: '/course/detail',
                  name: 'course-detail',
                  hideInMenu: true,
                  icon: 'smile',
                  component: './CourseInfo/courseData/index',
                },
              ],

            },

            {
              component: './404',
            },
          ],
        },
        {
          component: './404',
        },
      ],
    },
    {
      component: './404',
    },
  ],
  // Theme for antd: https://ant.design/docs/react/customize-theme-cn
  theme: {
    // ...darkTheme,
    'primary-color': defaultSettings.primaryColor,
  },
  // @ts-ignore
  title: false,
  ignoreMomentLocale: true,
  // proxy: proxy[REACT_APP_ENV || 'dev'],
  proxy: {
    '/app-admin/app-admin': {
      target: 'https://alidev-kid.iqidao.com/api/app-admin',
      // target:'http://192.168.1.113:8080',
      changeOrigin: true,
      pathRewrite: { '^/app-admin/app-admin': '' },
      headers: {
        Connection: 'keep-alive',
      },
    },
    // '/app-admin/teach-admin': {
    //   // target: 'http://192.168.0.116:8090/admin',
    //   target: 'https://alitest-kid.iqidao.com/api',
    //   changeOrigin: true,
    //   pathRewrite: { '^': '' },
    // },
    '/app-admin/teach-admin': {
      // target: 'http://192.168.0.116:8090/admin',
      target: 'https://alitest-kid.iqidao.com/api',
      changeOrigin: true,
      pathRewrite: { '^/app-admin': '' },
    },
    '/app-admin/teacher-admin': {
      // target: 'http://192.168.0.116:8090/admin',
      target: 'https://alidev-kid.iqidao.com/api/teacher-admin',
      changeOrigin: true,
      pathRewrite: { '^/app-admin/teacher-admin': '' },
    },
    // '/app-admin/teach-admin': {
    //   // target: 'http://192.168.0.116:8090/admin',
    //   target: 'https://alitest-kid.iqidao.com/api',
    //   changeOrigin: true,
    //   pathRewrite: { '^/app-admin': '' },
    // },
    // '/app-admin/teach-admin': {
    //   // target: 'http://192.168.0.116:8090/admin',
    //   target: 'http://teach.frp.fanjob.top',
    //   changeOrigin: true,
    //   pathRewrite: { '^/app-admin/teach-admin': '' },
    // },
    '/upm': {
      // target: 'http://192.168.0.116:8090/admin',
      target: 'https://alitest-upm.iqidao.com/api',
      changeOrigin: true,
      pathRewrite: { '^/upm': '' },
    },


    // '/app-admin/teach-admin/admin': {
    //   target: 'http://teach.frp.fanjob.top/admin',
    //   changeOrigin: true,
    //   pathRewrite: { '^/app-admin/teach-admin/admin': '' },
    // },
  },
  manifest: {
    basePath: '/web/teacher-amin/',
  },
  base: '/web/teacher-admin/',
  publicPath: cdnUrl,
  define: {
    REACT_APP_ENV: REACT_APP_ENV
  },
  devtool: "source-map"
});
